home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Shareware
/
IDimager Personal 4.2.0.3
/
setup_IDimager_Personal_V4.exe
/
{app}
/
web
/
modules
/
albumtree.psc
< prev
next >
Wrap
Text File
|
2008-06-02
|
12KB
|
256 lines
%code
const
cIndentString = ' '; // the trailing space is required for IE
var
AShowCounts: Boolean;
function StringRepeat(AString: WideString; ARepeat: Integer): WideString;
var
i: Integer;
begin
result := toWideString('');
for i := 1 to ARepeat do
result := result + AString;
end;
function DetermineScriptOnType (AType: Char): WideString;
begin
if AType = 'M' then
result := 'albumimages.psc'
else if AType = 'G' then
result := 'galleryimages.psc'
else if AType = 'C' then
result := 'collimages.psc';
end;
function FormatResult (AGUID: String; AName: WideString; ACount: Integer; AType: Char);
begin
result := toWideString('');
result := result + '<a href="javascript:getHTML(''%var:PageOffset/./modules/' + DetermineScriptOnType (AType) + ''', ''thumbs'', ''GUID=' + AGUID + ''');">';
if AShowCounts then
result := result + WideFormat ('%s [%d]', [AName, ACount])
else
result := result + AName;
result := result + '</a>';
end;
var
AParentGUID: String;
ALevel: Integer;
AModels: TImageModelItems;
AModel: TImageModel;
AGalleries: TImageGalleries;
AGallery: TImageGallery;
AColls: TImageCollections;
AColl: TImageCollection;
ASubColls: TImageCollections;
ASubColl: TImageCollection;
i: Integer;
AExpand: Boolean;
begin
result := toWideString('');
AShowCounts := (Request.Params.Values['showCounts'] = 'y');
AParentGUID := Trim(Request.Params.Values['GUID']);
if AParentGUID = '' then
AParentGUID := 'top';
AExpand := Request.Params.Values['expand'] ='y';
if not IsValidNumberString(Request.Params.Values['level'], False) then
ALevel := 0
else
ALevel := StrToInt(Request.Params.Values['level']);
if AParentGUID = 'top' then
begin
AModels := TImageModelItems.Create (TImageModelItem, '');
Catalog.EnumModels (AModels, False, False, AShowCounts);
for i := 0 to AModels.Count - 1 do
begin
AModel := AModels.Items[i].Model;
result := result + '<div id="' + AModel.GUID + '">';
result := result + '<a href="javascript:getHTML(''%var:PageOffset/./modules/albumtree.psc'', ''' + AModel.GUID + ''', ''GUID=' + AModel.GUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=y&level=' + IntToStr(ALevel + 1) + ''');">' +
' <img src="%var:PageOffset/images/expand.gif">' +
'</a> ' + FormatResult(AModel.GUID, AModel.ModelName, AModel.PhotoCount, 'M') +
'';
result := result + '</div>';
end;
AModels.Free;
end
else
begin
if ALevel = 1 then
begin
AModel := TImageModel.Create(nil);
Catalog.EnumModel (AParentGUID, AModel, AShowCounts);
if AExpand then
result := result + StringRepeat(cIndentString, ALevel - 1) +
'<a href="javascript:getHTML(''%var:PageOffset/./modules/albumtree.psc'', ''' + AParentGUID + ''', ''GUID=' + AParentGUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=n&level=' + IntToStr(ALevel) + ''');">' +
' <img src="%var:PageOffset/images/collapse.gif">' +
'</a> ' +
FormatResult(AParentGUID, AModel.ModelName, AModel.PhotoCount, 'M') +
''
else
result := result + StringRepeat(cIndentString, ALevel - 1) +
'<a href="javascript:getHTML(''%var:PageOffset/./modules/albumtree.psc'', ''' + AParentGUID + ''', ''GUID=' + AParentGUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=y&level=' + IntToStr(ALevel) + ''');">' +
' <img src="%var:PageOffset/images/expand.gif">' +
'</a> ' +
FormatResult(AParentGUID, AModel.ModelName, AModel.PhotoCount, 'M') +
'';
if AExpand then
begin
AGalleries := TImageGalleries.Create(TImageGallery, '');
AGalleries.Clear;
Catalog.EnumModelGalleries (AModel, AGalleries, AShowCounts);
for i := 0 to AGalleries.Count - 1 do
begin
AGallery := AGalleries.Items[i];
result := result + '<div id="' + AGallery.GUID + '">';
result := result + StringRepeat(cIndentString, ALevel) +
iif (not Catalog.GalleryHasCollections (AGallery.GUID),
'',
'<a href="javascript:getHTML(''%var:PageOffset/./modules/albumtree.psc'', ''' + AGallery.GUID + ''', ''GUID=' + AGallery.GUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=y&level=' + IntToStr(ALevel + 1) + ''');">' +
' <img src="%var:PageOffset/images/expand.gif">' +
'</a>'
) +
' ' +
FormatResult(AGallery.GUID, AGallery.GalleryName, AGallery.PhotoCount, 'G') +
'';
result := result + '</div>';
end;
AGalleries.Free;
end;
AModel.Free;
end
else if ALevel = 2 then
begin
AGallery := TImageGallery.Create(nil);
AGallery.GUID := AParentGUID;
Catalog.EnumModelGallery (AGallery, AShowCounts);
if AExpand then
result := result + StringRepeat(cIndentString, ALevel - 1) +
iif (not Catalog.GalleryHasCollections (AGallery.GUID),
'',
'<a href="javascript:getHTML(''%var:PageOffset/./modules/albumtree.psc'', ''' + AParentGUID + ''', ''GUID=' + AParentGUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=n&level=' + IntToStr(ALevel) + ''');">' +
' <img src="%var:PageOffset/images/collapse.gif">' +
'</a>'
) +
' ' +
FormatResult(AParentGUID, AGallery.GalleryName, AGallery.PhotoCount, 'G') +
''
else
result := result + StringRepeat(cIndentString, ALevel - 1) +
iif (not Catalog.GalleryHasCollections (AGallery.GUID),
'',
'<a href="javascript:getHTML(''%var:PageOffset/./modules/albumtree.psc'', ''' + AParentGUID + ''', ''GUID=' + AParentGUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=y&level=' + IntToStr(ALevel) + ''');">' +
' <img src="%var:PageOffset/images/expand.gif">' +
'</a>'
) +
' ' +
FormatResult(AParentGUID, AGallery.GalleryName, AGallery.PhotoCount, 'G') +
'';
if AExpand then
begin
AColls := TImageCollections.Create(TImageCollection, '');
Catalog.EnumGalleryCollections (AGallery, AColls, AShowCounts);
for i := 0 to AColls.Count - 1 do
begin
AColl := AColls.Items[i];
result := result + '<div id="' + AColl.GUID + '">';
result := result + StringRepeat(cIndentString, ALevel) +
iif (not Catalog.CollectionHasCollections (AColl.GUID),
'',
'<a href="javascript:getHTML(''%var:PageOffset/./modules/albumtree.psc'', ''' + AColl.GUID + ''', ''GUID=' + AColl.GUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=y&level=' + IntToStr(ALevel + 1) + ''');">' +
' <img src="%var:PageOffset/images/expand.gif">' +
'</a>'
) +
' ' +
FormatResult(AColl.GUID, AColl.CollectionName, AColl.PhotoCount, 'C') +
'';
result := result + '</div>';
end;
AColls.Free;
end;
AGallery.Free;
end
else if ALevel >= 2 then
begin
AColl := TImageCollection.Create(nil);
AColl.GUID := AParentGUID;
Catalog.EnumModelCollection (AColl, AShowCounts);
if AExpand then
result := result + StringRepeat(cIndentString, ALevel - 1) +
iif (not Catalog.CollectionHasCollections (AColl.GUID),
'',
'<a href="javascript:getHTML(''%var:PageOffset/./modules/albumtree.psc'', ''' + AParentGUID + ''', ''GUID=' + AParentGUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=n&level=' + IntToStr(ALevel) + ''');">' +
' <img src="%var:PageOffset/images/collapse.gif">' +
'</a>'
) +
' ' +
FormatResult(AParentGUID, AColl.CollectionName, AColl.PhotoCount, 'C') +
''
else
result := result + StringRepeat(cIndentString, ALevel - 1) +
iif (not Catalog.CollectionHasCollections (AColl.GUID),
'',
'<a href="javascript:getHTML(''%var:PageOffset/./modules/albumtree.psc'', ''' + AParentGUID + ''', ''GUID=' + AParentGUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=y&level=' + IntToStr(ALevel) + ''');">' +
' <img src="%var:PageOffset/images/expand.gif">' +
'</a>'
) +
' ' +
FormatResult(AParentGUID, AColl.CollectionName, AColl.PhotoCount, 'C') +
'';
if AExpand then
begin
ASubColls := TImageCollections.Create(TImageCollection, '');
Catalog.EnumCollectionCollections (AColl, ASubColls, AShowCounts);
for i := 0 to ASubColls.Count - 1 do
begin
ASubColl := ASubColls.Items[i];
result := result + '<div id="' + ASubColl.GUID + '">';
result := result + StringRepeat(cIndentString, ALevel) +
iif (not Catalog.CollectionHasCollections (ASubColl.GUID),
'',
'<a href="javascript:getHTML(''%var:PageOffset/./modules/albumtree.psc'', ''' + ASubColl.GUID + ''', ''GUID=' + ASubColl.GUID + '&showCounts=' + iif(AShowCounts, 'y', 'n') + '&expand=y&level=' + IntToStr(ALevel + 1) + ''');">' +
' <img src="%var:PageOffset/images/expand.gif">' +
'</a>'
) +
' ' +
FormatResult(ASubColl.GUID, ASubColl.CollectionName, ASubColl.PhotoCount, 'C') +
'';
result := result + '</div>';
end;
ASubColls.Free;
end;
AColl.Free;
end
end;
end;
%/code